import {Task} from '../models'
import dayjs from 'dayjs'
import jobs from '../jobs'
import * as $task from '../services/task'
module.exports = {
  title: '发布预布置作业',
  role: '*/5 * * * *',
  enable: true,
  async run () {
    let tasks = await Task.findAll({
      where: {
        isPublished: 0,
        prePublishAt: {$lte: dayjs().format('YYYY-MM-DD HH:mm:ss')}
      },
      limit: 200
    })
    tasks.forEach(n => {
      jobs.add('task-publish', {taskId: n.id})
    })
  }
}
